<?php if (!defined('THINK_PATH')) exit(); /*a:1:{s:86:"D:\php\PHPTutorial\WWW\anbo\tp5\public/../application/admin\view\scroe\editoffice.html";i:1605529650;}*/ ?>
<!DOCTYPE html>
<html class="x-admin-sm">
    
    <head>
        <meta charset="UTF-8">
        <title>欢迎页面-X-admin2.2</title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
        <link rel="stylesheet" href="/static/admin/css/font.css">
        <link rel="stylesheet" href="/static/admin/css/xadmin.css">
        <script type="text/javascript" src="/static/admin/lib/layui/layui.js" charset="utf-8"></script>
        <script type="text/javascript" src="/static/admin/js/xadmin.js"></script>
        <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
        <!--[if lt IE 9]>
            <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
            <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
        <![endif]-->
    </head>
    <body>
        <div class="layui-fluid">
            <div class="layui-row">
                <form class="layui-form">
                   <table class="layui-table" lay-skin="line">
                      <colgroup>
                        <col width="150">
                        <col width="150">
                        <col width="200">
                        <col>
                      </colgroup>
                      <thead>
                        <tr>
                          <th>姓名：<?php echo $data['username']; ?></th>
                          <th>班级：<?php echo $data['class_name']; ?></th>
                          <th>专业：<?php echo getMajorName($data['major_id']); ?></th>
                          <th>科目：<?php echo getSubjectName($data['subject_id']); ?></th>
                          <th>考试时间：<?php echo $data['add_time']; ?></th>
                        </tr> 
                      </thead>
                      <tbody>
                        <tr>
                          <td>单选题得分：<?php echo $data['single_scroe']; ?></td>
                          <td>多选题的分：<?php echo $data['selection_scroe']; ?></td>
                          <td>判断题得分：<?php echo $data['judge_scroe']; ?></td>
                          <td>操作题得分：<?php echo $data['single_scroe']; ?></td>
                          <td>总得分：<?php echo $data['scroe']; ?></td>
                        </tr>
                      </tbody>
                    </table> 
                    <!-- 传id -->
                    <input type="hidden" name="id" value="<?php echo $data['id']; ?>">
                    
                  <div class="layui-form-item layui-form-text">
                    <label for="content" class="layui-form-label">
                        单选题
                    </label>
                    <div class="layui-input-block">
                        <textarea placeholder="请输入内容" id="single" name="single" class="layui-textarea"><?php echo $data['single']; ?></textarea>
                    </div>
                  </div>

                  <div class="layui-form-item layui-form-text">
                    <label for="content" class="layui-form-label">
                        多选题
                    </label>
                    <div class="layui-input-block">
                        <textarea placeholder="请输入内容" id="selection" name="selection" class="layui-textarea"><?php echo $data['selection']; ?></textarea>
                    </div>
                  </div>

                  <div class="layui-form-item layui-form-text">
                    <label for="content" class="layui-form-label">
                        判断题
                    </label>
                    <div class="layui-input-block">
                        <textarea placeholder="请输入内容" id="judge" name="judge" class="layui-textarea"><?php echo $data['judge']; ?></textarea>
                    </div>
                  </div>

                  <div class="layui-form-item layui-form-text">
                    <label for="content" class="layui-form-label">
                        操作题
                    </label>
                    <div class="layui-input-block">
                        <textarea placeholder="请输入内容" id="operation" name="operation" class="layui-textarea"><?php echo $data['operation']; ?></textarea>
                    </div>
                  </div>
                    

                  <div class="layui-form-item">
                      <label for="L_repass" class="layui-form-label">
                      </label>
                      <button  class="layui-btn" lay-filter="edit" lay-submit="">
                          审阅
                      </button>
                  </div>
              </form>
            </div>
        </div>
        <script>
          layui.use(['form', 'layer'],
            function() {
                $ = layui.jquery;
                var form = layui.form,
                layer = layui.layer;


                //监听提交
                form.on('submit(edit)',
                function(data) {
                    console.log(data);
                    //发异步，把数据提交给php
                    $.post("<?php echo url('scroe/editoffice'); ?>",{data:filterData(data.field)},function (data){
                      if(data.code==1){
                        layer.alert(data.msg, {icon:6},function(){
                          xadmin.close();
                          xadmin.father_reload();
                      });
                    }else{
                      layer.alert(data.msg, {icon: 5},function(){
                        xadmin.close();
                        xadmin.father_reload();
                      });
                    }
                  });
                    return false;
                });
                filterData = function (data) {
                    var roleListIds = {};
                    var temp = {};
                    for (var key in data) {
                        if (key.indexOf("[") === -1) {
                            roleListIds[key] = data[key];
                        } else {
                            temp[key] = data[key];
                        }
                    }

                    var temp_arr = [];
                    for (var key in temp) {
                        var _arr = key.split("[");
                        var field = _arr[0];
                        if (temp_arr.indexOf(field) === -1) {
                            temp_arr.push(field);
                        }
                    }

                    for (var i in temp_arr) {
                        var _f = temp_arr[i];
                        var _temp = [];
                        for (var k in temp) {
                            console.log(k);
                            if (k.indexOf(_f) !== -1) {
                                _temp.push(temp[k])
                            }
                        }
                        roleListIds[_f] = _temp;
                    }
                    return roleListIds;
                };
              });


</script>
    </body>

</html>
